/**
 * Created by Administrator on 2017/4/25.
 */
var ChangePwd = require('../changePwd');
var Layer = require('../../../../src/libs/layer');
var Button = require('../../../../src/libs/button');
var AccountInfo = React.createClass({
    getDefaultProps:function(){
        return{
            realName: PageDM.realName.value,
            phoneNum: PageDM.phoneNum.value,
            ownPwd: PageDM.ownPwd.value
        }
    },
    getInitialState: function () {
      return {
          realName: this.props.realName,
          phoneNum: this.props.phoneNum,
          ownPwd: this.props.ownPwd
      }
    },
    resetForm:function(){
        this.refs.changeForm.reset();
    },
    showChangeLayer:function () {
        this.refs.loginCode.resetForm();
        PageDM.changeLoginLayer.showDialog();
    },
    componentDidMount:function(){
        var _this = this;
        UEventHub.on('LayerOpen',function (v) {
            _this.refs[v].layerOpen();

        });
        UEventHub.on('LayerClose',function (v) {
            _this.refs[v].layerClose();
        });
    },
    render: function(){
        var _this = this;
        return (
            <div className="my-info">
                <div className="title-account"><span>账号信息</span></div>
                <div className="item">
                    <div className="list">
                        <i className="iconfont icon-user"></i>
                        <span className="fc-light name">企业名称：</span>
                        <span className="fc-dark">{_this.state.realName?_this.state.realName:"您还未进行"}</span>
                        {_this.state.realName? '':<a href={PageDM.URL.financeLogin} className="fc-link open-bank-layer">融资登记</a>}
                    </div>
                    <div className="list">
                        <i className="iconfont icon-mobile"></i>
                        <span className="fc-light name">手<em></em>机：</span>
                        <span className="fc-dark">{_this.state.phoneNum?_this.state.phoneNum:"未绑定"}</span>
                    </div>
                    <div className="list">
                        <i className="iconfont icon-password"></i>
                        <span className="fc-light name">登录密码：</span>
                        <span className="fc-dark">{_this.state.ownPwd ? "******" : "未设置"}</span>
                        <a href="javascript:;" className="fc-link open-layer" data-action="layer-change-password" onClick={_this.showChangeLayer}>修改</a>
                    </div>
                </div>
                <Layer ref={PageDM.changeLoginLayer.dmbind} getContainer="my-info" width="720px"  className="layer-addbank" closeBack={PageDM.changeLoginLayer.closeBack?PageDM.changeLoginLayer.closeBack:''}>
                    <ChangePwd ref="loginCode" title="修改密码" oldPwd={PageDM.loginPwd} newPwd={PageDM.newPwd} checkNewPwd={PageDM.newPwd2} phoneCode={PageDM.phoneCode} getCode={PageDM.getBtnCode}/>
                    <div className="alert-button">
                        <Button className="btn btn-confirm" value="确认" onClick={PageDM.changeLoginLayer.confirmBack} dmbind={PageDM.changeLoginLayer.dmbind}/>
                        <input type="button" className="btn btn-cancel close" value="取消" onClick={PageDM.changeLoginLayer.cancelBack}/>
                    </div>
                </Layer>
            </div>
        )
    }
});
module.exports = AccountInfo;